# 作者：小七
# 2024年12月28日

# 1
def use_tuple():
    info_tuple = ("zhangsan", 18, 1.75)
    for i in info_tuple:
        print(i)

    print(info_tuple[0])

    print(info_tuple.count("zhangsan"))

    print(len(info_tuple))


def use_dict():
    xiaoming_dict = {"name": "小明",
                     "qq": "123456",
                     "phone": "10086"}

    print(xiaoming_dict["name"])
    xiaoming_dict["name"] = "小小明"
    for k, v in xiaoming_dict.items():
        print(k, v)
    for j in xiaoming_dict:
        print(j, xiaoming_dict[j])
    print(len(xiaoming_dict))


def use_str():
    s1 = 'abc bcd 哈哈哈'
    print(s1.split())
    s2 = 'abc\nbcd\nef'
    print(s2.splitlines())
    s3 = 'abc\r\nbcd\r\nef'
    print(s3.splitlines(True))
    str_list = ['a', 'b', 'c', 'd', 'e']
    print(''.join(str_list))
    num_str = "0123456789"
    print(num_str[2:6])
    print(num_str[2:])
    print(num_str[:6])
    print(num_str[:])
    print(num_str[::2])
    print(num_str[1::2])
    print(num_str[2:-1])
    print(num_str[-2:])
    print(num_str[::-1])


def use_set():
    fruits = {"apple", "banana", "cherry"}
    fruits.add("orange")
    print(fruits)
    x = {"apple", "banana", "cherry"}
    y = {"google", "microsoft", "apple"}
    z = x.difference(y)
    print(z)
    x.difference_update(y)
    print(x)
    fruits = {"apple", "banana", "cherry"}
    fruits.discard("banana")
    print(fruits)
    x = {"apple", "banana", "cherry"}
    z = x.symmetric_difference(y)
    print(z)
    z = x.union(y)
    print(z)
    print('apple' in z)
    print(x - y)
    print(x & y)
    print(x | y)
    print(x ^ y)


def test(name, num=66):
    print(name, num)


# if __name__ == '__main__':
#     use_tuple()
#     use_dict()
#     use_str()
#     use_set()
#     test(1)

# 2

# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# b = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
# for k in set(a) & set(b):
#     print(k, end=' ')


# 3

def vote(a):
    c = 0
    v = 0
    k = 0
    for i in a:
        if v == 0:
            c = a[k]
        elif c != a[i]:
            v -= 1
        else:
            v += 1
        k += 1
    print(c)


# a = [1, 2, 1, 3, 1, 4, 1, 5, 1, 1]
# vote(a)

# 4

# 相同点：
# 容器类型：
#
# 列表、元组和字典都是容器类型数据结构，可以存储多个元素。
# 支持迭代：
#
# 都支持迭代，可以用 for 循环进行遍历。
# 支持不同类型的元素：
#
# 可以存储不同类型的数据，例如整数、字符串、其他列表、元组等。
# 支持嵌套：
#
# 列表、元组和字典都支持嵌套，可以将它们作为元素存储在其他容器中。
# 不同点：
# 列表（List）：有序、可变，适合存储一组数据，并可以随时修改元素。
# 元组（Tuple）：有序、不可变，适合存储常量数据，不允许修改。
# 字典（Dictionary）：无序（但 Python 3.7+ 保持顺序）、可变，适合存储键值对映射，键是唯一的。

# 5

# a=(1,2,3)
# b={4,5,6}
# print(list(a)+list(b))

# 6
#
# a = [1, 2, 3, 4, 5, 6]
# a.append(7)
# a.insert(0, 0)
# print(a)

# 7

# a = [0, 1, 2, 3, 4, 5, 6, 7]
# print(a[::-1])

# 8

# a = [0, 1, 2, 3, 4, 5, 6, 7]
# a.reverse()
# print(a.index(5))

# 9

# a = [True, False, 0, 1, 2]
# print(a.count(False), a.count(True), a.count(0), a.count(1), a.count(2))

# 10

# a = [True, 1, 0, 'x', None, 'x', False, 2, True]
#
#
# b = [i for i in a if i != 'x']
#
#
# print(b)

# 11

# a = [True, 1, 0, 'x', None, 'x', False, 2, True]
#
# del a[4]
# print(a)

# 12

# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# b = [x for x in a if a.index(x) % 2 == 0]
# print(b)

# 13

# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# a.clear()
# print(a)

# 14
# a = [3, 0, 8, 5, 7]
# a.sort()
# print(a)
# a.sort(reverse=True)
# print(a)

# 15

# a = [3, 0, 8, 5, 7]
# b = len(a)
# for j in range(b):
#     if a[j] > 5:
#         a[j] = 1
#     else:
#         a[j] = 0
# print(a)

# 16

# a = ['x', 'y', 'z']
# for i in a:
#     print(i, a.index(i))

# 17

# a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# b = [i for i in a if i % 2 == 0]
# c = [i for i in a if i % 2 != 0]
# print(b, c)

# 18

# a= [[6, 5], [3, 7], [2, 8]]
# a.sort()
# print(a)

# 19

# a = [1, 4, 7, 2, 5, 8]
# a[3:3] = ['x', 'y', 'z']
# print(a)

# 20

# a = [i for i in range(5, 51)]
# print(a)

# 22

a = ['x', 'y', 'z']
b = [1, 2, 3]
print(list(zip(a, b)))